from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class gui_fake :
    def __init__ ( self ) :
        self . _gui_set_entry_text = None
        self . _gui_destroy_entry = None
        self . _gui_create_entry_request = None
        self . _gui_entry_text_request = None
    def gui_create_entry_request ( self , master , borderwidth ) :
        self . _gui_create_entry_request = [ master , borderwidth ]
    def gui_entry_text_request ( self , entry ) :
        self . _gui_entry_text_request = entry
    def gui_set_entry_text ( self , entry , text ) :
        self . _gui_set_entry_text = [ entry , text ]
    def gui_destroy_entry ( self , entry ) :
        self . _gui_destroy_entry = entry

class mediator_gui_entry_tests : 
    'mediator_gui_entry'
    def __init__ ( self , test ) :
        self . _test = test
        self . _gui = gui_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'gui' 
            , self . _gui 
            , None
            ) )
    def test_gui_create_entry ( self ) :
        self . _mediator . gui_create_entry_request ( 'my master' , 'my borderwidth' )
        self . _test . assume_equal ( self . _gui . _gui_create_entry_request ,
            [ 'my master'
            , 'my borderwidth'
            ] )
    def test_gui_create_entry_arg_names ( self ) :
        self . _mediator . gui_create_entry_request ( master = 'my master' , borderwidth = 'my borderwidth' )
        self . _test . assume_equal ( self . _gui . _gui_create_entry_request ,
            [ 'my master'
            , 'my borderwidth'
            ] )
    def test_gui_entry_text_request ( self ) :
        self . _mediator . gui_entry_text_request ( 'my entry' )
        self . _test . assume_equal ( self . _gui . _gui_entry_text_request , 'my entry' )
    def test_gui_set_entry_text ( self ) :
        self . _mediator . gui_set_entry_text ( 'my entry' , 'my text' )
        self . _test . assume_equal ( self . _gui . _gui_set_entry_text , 
            [ 'my entry' 
            , 'my text'
            ] )
    def test_gui_destroy_entry ( self ) :
        self . _mediator . gui_destroy_entry ( 'my entry' )
        self . _test . assume_equal ( self . _gui . _gui_destroy_entry , 'my entry' )
